<html>
<head><meta charset="utf-8"><title>stricter-unions · t-lang/wg-unsafe-code-guidelines · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/index.html">t-lang/wg-unsafe-code-guidelines</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/stricter-unions.html">stricter-unions</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="133869610"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/stricter-unions/near/133869610" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/stricter-unions.html#133869610">(Sep 13 2018 at 08:28)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> <span class="user-mention" data-user-id="116009">@nikomatsakis</span> I might be wrong, but we could have an opt-in for unions that are closer in their semantics to enums, where variants are effectively disjoint in their accesses, and using the union to "transmute" would be UB <a href="https://www.reddit.com/r/rust/comments/9ffqct/blog_measuring_smallvec_footprint_with/e5w7fi6?context=9" target="_blank" title="https://www.reddit.com/r/rust/comments/9ffqct/blog_measuring_smallvec_footprint_with/e5w7fi6?context=9">https://www.reddit.com/r/rust/comments/9ffqct/blog_measuring_smallvec_footprint_with/e5w7fi6?context=9</a></p>



<a name="133887748"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/stricter-unions/near/133887748" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/stricter-unions.html#133887748">(Sep 13 2018 at 14:18)</a>:</h4>
<p>probably, yes</p>



<a name="134115438"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/stricter-unions/near/134115438" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/stricter-unions.html#134115438">(Sep 17 2018 at 17:41)</a>:</h4>
<p>Why does this <code>SmallVec</code> optimization need extra union behavior?</p>



<a name="134115504"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/stricter-unions/near/134115504" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/stricter-unions.html#134115504">(Sep 17 2018 at 17:42)</a>:</h4>
<p>I am somewhat doubtful about any notion of an "active variant"... that'd somehow have to be stored in "shadow data" on the abstract machine, and it is not clear to me where that data would live and how we would even know to access it</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>